<?php


namespace app\service\utils;


use dh2y\qrcode\QRcode;

class QrcodeService
{
//    public static function createQrcode($url, $userId, $inviteCode, $logo)
//    {
//        $code = new QRcode();
//        //生成二维码
//        $rootPath = public_path();
//        $path = '/upload/qrcode/' . $userId . '.png';
//        $filePath = $rootPath . $path;
//        $code->png($url, $filePath, 14)
//            ->logo($logo)
//            ->background(192, 710)
////            ->text('二维码', 20, ['center', 460], '#ff4351')
//            ->text($inviteCode, 50, ['center', 1450], '#ff4351');
//        return $path;
//    }


    public static function createQrcode($url)
    {
        try {
            $code = new QRcode();
            //生成二维码
            $code->png($url, false, 6);
            return $code->getPath();
        } catch (\Exception $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
}